
function extend(destination, source, deep) {
	if (deep) {
		for ( var p in source) {
			var type = getType(source[p]);
			if (type == "array" || type == "object") {	// 当对象中还有对象或者数组时
				destination[p] = type == "array" ? [] : {};
				arguments.callee(destination[p], source[p]);
			} else {
				destination[p] = source[p];
			}
		}
	} else {
		for ( var property in source) {
			destination[property] = source[property];
		}
	}
}
function getType (o) {
	var _t;
	return ((_t = typeof (o)) == "object" ? o == null && "null" || Object.prototype.toString.call(o).slice(8, -1) : _t).toLowerCase();
}

var test = {
	a : "aa",
	b : "bb",
	c : {
		d : "css",
		e : "cdd"
	}
};
var test1 = {};
extend(test1, test, true);
test1.c.d = "change";	// 改变test1的c属性对象的d属性
alert(test.c.d); 		// 不影响test
